<?php

/**
 * Trida slouzi pro rozsireni funkcnosti tridy \Gridito\DoctrineQueryBuilderModel,
 * ktera nema podporu pro neciselny primarni klic.
 *
 * @author David Dusek
 */
namespace CMS;

class DoctrineQueryBuilderModel extends \Gridito\DoctrineQueryBuilderModel {
    public function getItemByUniqueId($uniqueId)
    {
            $qb = clone $this->qb;		

            if (intval($uniqueId) > 0) {
                $id = (int) $uniqueId;
            } else {
                $id = "'$uniqueId'";
            }

            return $qb->andWhere($this->qb->getRootAlias() . '.' . $this->getPrimaryKey() . ' = ' . $id)->getQuery()->getSingleResult();                
    }
}
